import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Role } from './entities/role.entity';
import { AskForm } from './entities/askform.entity';
import { ReplyForm } from './entities/replyform.entity';
import { RoleController } from './controllers/role.controller';
import { RoleService } from './services/role.service';
import { AskFormController } from './controllers/askform.controller';
import { AskFormService } from './services/askform.service';
import { ReplyFormController } from './controllers/replyform.controller';
import { ReplyFormService } from './services/replyform.service';
import { AuthController } from './controllers/auth.controller';
import { AuthService } from './services/auth.service';
import { JwtModule } from '@nestjs/jwt';

@Module({
  imports: [
    ConfigModule.forRoot(),
    TypeOrmModule.forRoot({
      type: 'sqlite',
      database: 'database.sqlite',
      entities: [Role, AskForm, ReplyForm],
      synchronize: true,
    }),
    TypeOrmModule.forFeature([Role, AskForm, ReplyForm]),
    JwtModule.register({
      secret: 'your_secret_key', // 请使用环境变量
      signOptions: { expiresIn: '60s' }, // 令牌过期时间
    }),
  ],
  controllers: [RoleController, AskFormController, ReplyFormController, AuthController],
  providers: [RoleService, AskFormService, ReplyFormService, AuthService],
})
export class AppModule { }
